import pojo.Evaluate;
import pojo.Movie;
import pojo.Time;
import pojo.User;
import system.impl.MovieSystemImpl;
import tool.ReaderUtil;

import java.util.List;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        System.out.println("233");

        Time time = new Time(2012,12,  1);
        System.out.println(time);

        List<Movie> movies = ReaderUtil.readMovie("moviedata/movie.txt");
        for (Movie movie : movies) {
            System.out.println(movie);
        }

        //读取用户
        List<User> users = ReaderUtil.readUser("moviedata/users.txt");
        for (User user : users) {
            System.out.println(user);
        }

        //读取评价
        List<Evaluate> evaluates = ReaderUtil.readEvaluate("moviedata/rate.txt");
        for (Evaluate evaluate : evaluates) {
            System.out.println(evaluate);
        }

        MovieSystemImpl movieSystem = new MovieSystemImpl();
        movieSystem.test();
        List<Movie> topMovies = movieSystem.getTopMovies(3);
        for (Movie movie : topMovies) {
            System.out.println("-");
            System.out.println(movie);
        }

        System.out.println("-=-=-=--=-=-=-=-=--==");
        Map<User, List<Movie>> topMoviesByUser = movieSystem.getTopMoviesByUser(3);
        for (Map.Entry<User, List<Movie>> entry : topMoviesByUser.entrySet()) {
            System.out.println(entry.getKey());
            for (Movie movie : entry.getValue()) {
                System.out.println(movie);
            }
            System.out.println("-----------------");
        }

        //
        System.out.println("评价最多的");
        List<Movie> topMoviesByEvaluate = movieSystem.getTopMoviesByEvaluate(3);
        for (Movie movie : topMoviesByEvaluate) {
            System.out.println(movie);
        }

        System.out.println("最多和人数");
        Map<Movie, Integer> topMoviesByScore = movieSystem.getTopMoviesByScore(3);
        //遍历
        for (Map.Entry<Movie, Integer> entry : topMoviesByScore.entrySet()) {
            System.out.println(entry.getKey() + "人数" + entry.getValue());
        }

        //前3名
        System.out.println("前3名");
        List<Movie> topEvaluates = movieSystem.getTopEvaluates(3);
        for (Movie movie : topEvaluates) {
            System.out.println(movie);
        }

        //求2017年上映的电影中，评分最高的3部剧情类电影
        System.out.println("求2017年上映的电影中，评分最高的3部剧情类电影");
        List<Movie> theMo = movieSystem.getTopMoviesByYear(2017, 3, "剧情");

        for (Movie movie : theMo) {
            System.out.println(movie);
        }

        //getTopMoviesBySex
        System.out.println("getTopMoviesBySex");
        List<Movie> topMoviesBySex = movieSystem.getTopMoviesBySex(3, "男");
        for (Movie movie : topMoviesBySex) {
            System.out.println(movie);
        }

        System.out.println("女生最喜欢的3部电影");
        List<Movie> topMoviesBySex1 = movieSystem.getTopMoviesBySex(3, "女");
        for (Movie movie : topMoviesBySex1) {
            System.out.println(movie);
        }
    }
}
